from datetime import datetime
from google.appengine.ext import db

WINDOW_SIZE = 20

class Url(db.Model):
    label = db.StringProperty()
    url = db.StringProperty()
    added = db.DateTimeProperty(auto_now_add = True)
    
    @classmethod
    def scroll_input(cls, label, url):
        objs = cls.all().order("-added")
        if objs.count() >= WINDOW_SIZE:
            objs[WINDOW_SIZE-1].delete()
        cls(label = label, url = url).put()